
import {getApi,postApi} from './request'
import {getProRequestData,pullProRequestData,editProRequestData,delProRequestData,loginProRequestData} from './types'

//登陆验证
export async function proLogin(data : loginProRequestData) {
  try {
    const res:any = await postApi('auth/login',data);
    return res;

  } catch (error) {
    console.error(error); // 处理错误
    return "error-0000"
  }
}

//获取项目列表
export async function proGetList() {
    try {
      const res:any = await getApi('programs/programList');
      return res.data.data;
    } catch (error) {
      console.error(error); // 处理错误
      return "error-0000"
    }
  }


//获取项目
export async function proGetById(data:getProRequestData) {
  try {
    const res:any = await getApi('programs/getProgram',data);
    return res.data.data;

  } catch (error) {
    console.error(error); // 处理错误
    return "error-0000"
  }
}


//新建项目
export async function proPull(data:pullProRequestData) {
  try {
    const res = await postApi('programs/pullProgram',data);
    return res;

  } catch (error) {
    console.error(error); // 处理错误
    return "error-0000"
  }
}

//修改项目
export async function proEdit(data:editProRequestData) {
  try {
    const res = await postApi('programs/editProgram',data);
    return res;

  } catch (error) {
    console.error(error); // 处理错误
    return "error-0000"
  }
}

//删除项目
export async function proDel(data:delProRequestData) {
  try {
    const res = await postApi('programs/delProgram',data);
    return res;

  } catch (error) {
    console.error(error); // 处理错误
    return "error-0000"
  }
}


//删除过程
export async function processDel(data:any) {
  try {
    const res = await postApi('programs/delProcess',data);
    return res;

  } catch (error) {
    console.error(error); // 处理错误
    return "error-0000"
  }
}

//获取新闻
export async function newsGet() {
  try {
    const res = await getApi('news');
    return res;
  } catch (error) {
    console.error(error); // 处理错误
    return "error-0000"
  }
}

//图片上传
export async function uploadImg(data:any) {
  try {
    const res = await postApi('uploadImg',data);
    return res;
  } catch (error) {
    console.error(error); // 处理错误
    return "error-0000"
  }
}

